package com.konsung.ksdc.manager.community;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * 创建者     kgh
 * 创建时间   2016/5/16 14:09
 * 描述  聊天社区
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */
public class CommunityPagerAdapter extends PagerAdapter {
    private List<View> viewsToShow;

    /**
     * 构造器
     * @param viewsToShow 控件
     */
    public CommunityPagerAdapter(List<View> viewsToShow) {
        this.viewsToShow = viewsToShow;
    }

    @Override
    public int getCount() {
        return viewsToShow.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object o) {
        return view == o;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewsToShow.get(position));
        return viewsToShow.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
